/**
 * 
 */
package me.myachievements.web.restricted.goal;

import org.apache.wicket.PageParameters;
import org.apache.wicket.datetime.DateConverter;
import org.apache.wicket.datetime.StyleDateConverter;
import org.apache.wicket.datetime.markup.html.basic.DateLabel;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.PropertyListView;
import org.apache.wicket.spring.injection.annot.SpringBean;

import me.myachievements.persistence.goal.Goal;
import me.myachievements.web.goal.GoalListModel;

/**
 * @author besseym
 *
 */
public class GoalListView extends PropertyListView<Goal> {
	
//	@SpringBean(name="dateConverter")
//	private DateConverter dateConverter;

	/**
	 * Constructor
	 * @param id
	 */
	public GoalListView(String id) {
		super(id, new GoalListModel());
	}

	/*
	 * (non-Javadoc)
	 * @see me.myachievements.web.target.TargetListView#populateItem(org.apache.wicket.markup.html.list.ListItem)
	 */
	protected void populateItem(final ListItem<Goal> item) {
		
		item.add(new Label("exposed"));
		item.add(new Label("rank"));
		item.add(new Label("title"));
		DateConverter dateConverter = new StyleDateConverter("M-", false);
		item.add(new DateLabel("completeBy", dateConverter));
		item.add(new Label("priority"));
		
		final Goal goal = (Goal)item.getModelObject();
		Long id = goal.getId();
		
		PageParameters pageParameters = new PageParameters(); 
		pageParameters.add("id", id.toString());
		item.add(new BookmarkablePageLink<GoalUpdatePage>("edit", GoalUpdatePage.class, pageParameters));
	}

}
